<template>
  <view>
    <!-- 搜索组件 -->
    <UgoSearch></UgoSearch>

    <!-- 轮播图 -->
    <view class="swiper">
      <u-swiper :list="swiperList" name="image_src" height="340"></u-swiper>
    </view>

    <!-- nav -->
    <view class="nav u-flex">
      <navigator
        v-for="item in navList"
        :key="item.name"
        class="u-flex-1 u-p-15"
      >
        <u-image width="100%" :src="item.image_src" mode="widthFix"></u-image>
      </navigator>
    </view>

    <!-- 楼层 -->
    <view class="floor">
      <view
        class="floor-group"
        v-for="item1 in floorList"
        :key="item1.floor_title.name"
      >
        <view class="floor-title">
          <u-image
            width="100%"
            mode="widthFix"
            :src="item1.floor_title.image_src"
          ></u-image>
        </view>
        <view class="floor-list">
          <navigator v-for="item2 in item1.product_list" :key="item2.name">
            <u-image
              :src="item2.image_src"
              width="100%"
              height="100%"
              mode="scaleToFill"
            ></u-image>
          </navigator>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 轮播图数组
      swiperList: [],
      // 导航数组
      navList: [],
      // 楼层数组
      floorList: [],
    };
  },
  // 页面开始加载的时候，发送请求
  onLoad() {
    // 获取轮播图数据
    this.getSwiper();
    // 获取导航数据
    this.getNav();
    // 获取楼层数据
    this.getFloor();
  },
  methods: {
    // 获取轮播图数据
    async getSwiper() {
      this.swiperList= await this.$u.get("/home/swiperdata");
    
    },

    // 获取导航数据
    async getNav() {
      this.navList= await this.$u.get("/home/catitems");
    },

    // 获取楼层数据
    async getFloor() {
      this.floorList= await this.$u.get("/home/floordata");
    },
  },
};
</script>

<style lang="scss">
.floor-group {
  margin-top: 20rpx;
}
.floor-list {
  //  清除浮动
  overflow: hidden;
  padding: 0 12rpx;
  navigator {
    float: left;
  }
  navigator {
    width: 232rpx;
    height: 386rpx;
  }
  navigator:nth-last-child(-n + 4) {
    width: 233rpx;
    height: 188rpx;
  }
  navigator:nth-child(2),
  navigator:nth-child(4) {
    margin: 0 15rpx;
  }
  navigator:nth-last-child(-n + 2) {
    margin-top: 10rpx;
  }
}
</style>
